<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page import="java.io.FileWriter,java.io.BufferedWriter,java.io.InputStream,java.util.Properties,java.io.IOException;" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<form action="Assign1.jsp" method="get">
Enter some text: <input type="text" name="someText">

<input type="submit" value="Submit">
</form>

<%
String text = request.getParameter("someText");
if (text != null && !text.isEmpty()) {
	
		ServletContext servletContext  = this.getServletContext();
		InputStream is = servletContext.getResourceAsStream("/WEB-INF/LogFile.properties");
		Properties props = new Properties();
		try {
		props.load(is);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
		String logDir = props.getProperty("logPath", "C:\\Downloads");
	
    String logFile = logDir + "\\someText.txt";
	
	
	String fileName = logFile;//Utility.getFileName(this);
	FileWriter fstream = new FileWriter(fileName);
	BufferedWriter writer = new BufferedWriter(fstream);
	writer.write(text);
	writer.close();
	
%>

	<form action="Download" method="get">
	<input type="submit" value="Download">
	</form>
<%	
}
%>

<body>

</body>
</html>